<?php

namespace App\Models\Personal;
use Illuminate\Database\Eloquent\Model;

class Resume extends Model{
    //设置表的类型和表名
    protected $table='resume';
    protected $primaryKey='id';
    public $timestamps=false;
    protected $guarded = [];

    //这里添加了关联ResumeExtra 简历附加信息
    public function withResumeExtra(){
        return $this->hasMany('App\Models\Personal\ResumeExtra','resume_id','id');
    }
    //简历和教育经历关系
    public function education_exp(){
        return $this->hasOne('App\Models\Personal\ResumeEducationExp','resume_id','id')->select('resume_id','school');
    }

    /**
     * 简历与工作经历
     */
    public function withWorkExp(){
        return $this->hasMany('App\Models\Personal\ResumeWorkExp','resume_id','id');
    }

    /** 更新迅搜状态
     * @param $id
     */
    public static function updateXSStatus($id)
    {
        if ($id > 0) {
            Resume::where(['id' => $id, 'xs_status' => 1])
                ->update(['xs_status' => 0]);
        }
    }

}